package com.wjj.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.wjj.entity.Brand;
import com.wjj.entity.Goods;
import com.wjj.entity.Shopping;

public interface GoodsDao {
	@Insert("INSERT INTO `t_brand` (`id`, `name`, `pic`) VALUES (#{id}, #{name}, #{pic});")
	void addBrand(Brand brand);
	//追加
	@Select("select * from t_brand")
	List<Brand> getBrand();
	//添加
	@Insert("INSERT INTO `t_goods` (`id`, `name`, `brand_id`, `pic`, `price`, `describe`) VALUES (NULL, #{name}, #{brandId}, #{pic}, #{price}, #{describe});")
	void addGoods(Goods goods);
	//购买商品
	List<Goods> selectGoods();
	//	查询所有的品牌
	List<Brand> selectBrand();
	//找到所有品牌下的所有商品
	List<Goods> listGoods(Integer id);
	//加入购物车
	@Insert("INSERT INTO `t_shopping` (`id`, `goods_id`, `brand_id`, `num`) VALUES (NULL, #{id}, NULL, num+1);")
	int addShopping(Integer id);
	//查看购物车
	@Select("SELECT * FROM t_shopping s LEFT JOIN t_goods g on g.id = s.goods_id")
	List<Shopping> selectShopping();
	@Select("SELECT * FROM t_shopping where goods_id = #{id}")
	List<Shopping> selectShoppings(Integer id);
	@Update("UPDATE `t_shopping` SET `num`=num+1 WHERE goods_id = #{id}")
	int setShopping(Integer id);
	
}
